#include <stdio.h>
#include <string.h>

char *memfind(char *src, char *sub, int srclen)
{
	char *p1 = NULL;
	char *p2 = NULL;
	char *p3 = NULL;
	char *p4 = NULL;
	int i = 0, j;
	
	p1 = src;
	for (; i<srclen; i++)
	{
		p2 = p1;
		p3 = sub;
		j = 0;
		
		while (j<strlen(sub))
		{
			if (*p2 == *p3)
			{
				p2++;
				p3++;
				j++;
			}
			else
				break;
		}
		if (j == strlen(sub))
		{
			return p1;
		}
		p1++;
	}
	return NULL;
}

int main()
{
	char *str = "luzhibangaicaijiali1314'\0'chengxuyunxinggggggg";
	char *p = NULL;
	p = memfind(str, "ceng", 40);
	printf("p: %s\n", p);
	return 0;
}
